package com.example.hzq.zqb.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.hzq.zqb.R;
import com.example.hzq.zqb.bean.MyshopBean;
import com.example.hzq.zqb.model.Model;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

import static com.example.hzq.zqb.activity.LoginActivity.u_id;

/**
 * Created by hzq on 2017/7/12.
 */

public class MyshopActivity extends AppCompatActivity implements View.OnClickListener{
    private ImageButton back;
    private TextView top,name;
    private LinearLayout photo,add,model,manger,transation,wuliu,kehu;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.myshop);
        back=(ImageButton)findViewById(R.id.back1);
        top=(TextView)findViewById(R.id.toptext);
        name=(TextView)findViewById(R.id.ms_shopname);
        photo=(LinearLayout)findViewById(R.id.ms_photo);
        add=(LinearLayout)findViewById(R.id.ms_addlayout);
        model=(LinearLayout)findViewById(R.id.ms_model);
        manger=(LinearLayout)findViewById(R.id.ms_manage);
        transation=(LinearLayout)findViewById(R.id.ms_transaction);
        wuliu=(LinearLayout)findViewById(R.id.ms_wuliu);
        kehu=(LinearLayout)findViewById(R.id.ms_kehu);
        top.setText("我的微创小屋");
        Model model1=new Model();
        Call<MyshopBean>call=model1.getShopName(u_id);
        call.enqueue(new Callback<MyshopBean>() {
            @Override
            public void onResponse(Call<MyshopBean> call, Response<MyshopBean> response) {
                if (response.isSuccessful()&&response.body()!=null){
                    name.setText(response.body().getName());
                }
            }

            @Override
            public void onFailure(Call<MyshopBean> call, Throwable t) {
                Toast.makeText(MyshopActivity.this,"404.myshopactivity",Toast.LENGTH_SHORT).show();
            }
        });
        photo.setOnClickListener(this);
        back.setOnClickListener(this);
        add.setOnClickListener(this);
        model.setOnClickListener(this);
        manger.setOnClickListener(this);
        transation.setOnClickListener(this);
        wuliu.setOnClickListener(this);
        kehu.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.back1:
                finish();
                break;
            case R.id.ms_photo:
                Toast.makeText(MyshopActivity.this,"photo",Toast.LENGTH_SHORT).show();
                break;
            case R.id.ms_addlayout:
                Toast.makeText(MyshopActivity.this,"add",Toast.LENGTH_SHORT).show();
                break;
            case R.id.ms_model:
                Toast.makeText(MyshopActivity.this,"model",Toast.LENGTH_SHORT).show();
                break;
            case R.id.ms_manage:
                Toast.makeText(MyshopActivity.this,"manager",Toast.LENGTH_SHORT).show();
                break;
            case R.id.ms_transaction:
                Toast.makeText(MyshopActivity.this,"transation",Toast.LENGTH_SHORT).show();
                break;
            case R.id.ms_wuliu:
                Toast.makeText(MyshopActivity.this,"wuliu",Toast.LENGTH_SHORT).show();
                break;
            case R.id.ms_kehu:
                Toast.makeText(MyshopActivity.this,"kehu",Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
